package com.villaday.idf.adapter3;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.model3.BrandListEntity;
import com.villaday.idf.model3.HotelSimilyEntity;

import java.util.ArrayList;
import java.util.List;

public class FindHousBrandListAdapter extends AbsRecyclerViewAdapter<BrandListEntity.BodyBean.ListBean> {

    public FindHousBrandListAdapter(Context context) {
        super(context, com.villaday.idf.R.layout.recycle_fhwsd_near);
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, BrandListEntity.BodyBean.ListBean d, int position) {
//        LogUtil.jLog().e(d.getLevelName() + "   " + d.getCurrentPriceValue() + "   " + d.getImageURL());
      try{
          holder.bindTextView(R.id.tv_fn_title, d.getName())
                  .bindTextView(R.id.tv_fn_type, d.getLevelName())
                  .bindTextViewWithHtml(R.id.vw_fn_money_left, "&yen;")
                  .bindTextViewWithHtml(R.id.tv_fhwsd_money, "&yen;"+ d.getCurrentPriceValue() == null ? "暂无" : d.getCurrentPriceValue())
                  .bindSimpleDraweeView(R.id.sdv_near, d.getImageURL());

          TextView tvDistance = (TextView) holder.getView(R.id.tv_fn_distance);
          TextView tvLine = (TextView) holder.getView(R.id.tv_fn_distance);

          if (d.getDistance() != -1 && d.getDistance() !=0) {
              String htmlStr = "相距 " + "&yen;<font color='#FEC24A'>" + d.getDistance() + " </font>km";
              tvDistance.setText(Html.fromHtml(htmlStr));
          } else {
              tvDistance.setVisibility(View.GONE);
              tvLine.setVisibility(View.GONE);
          }

          TextView tv1 = (TextView) holder.getView(R.id.tv_fn_label1);
          TextView tv2 = (TextView) holder.getView(R.id.tv_fn_label2);
          TextView tv3 = (TextView) holder.getView(R.id.tv_fn_label3);
          List<TextView> list = new ArrayList<>();
          list.add(tv1);
          list.add(tv2);
          list.add(tv3);
          List<String> tags = (List<String>) d.getTags();
          if (tags != null && tags.size() != 0) {
              for (int i = 0; i < tags.size(); i++) {
                  if (i < 3) {
                      list.get(i).setVisibility(View.VISIBLE);
                      list.get(i).setText(tags.get(i));
                  }
              }
          }else {
              tv1.setVisibility(View.INVISIBLE);
              tv2.setVisibility(View.INVISIBLE);
              tv3.setVisibility(View.INVISIBLE);
          }
      }catch (Exception e){
          e.printStackTrace();
      }
    }
}
